<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第三周作业</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 800px;
            margin: 20px auto;
            padding: 20px;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h1 {
            text-align: center;
            color: #333;
        }
        .content {
            margin-top: 20px;
            padding: 20px;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
        }
    </style>
</head>
<body>
    <script>
        alert("这是可爱的起始展示页喵")

</script>
    <div class="container">
        <h1>一些字符串</h1>
        <p> 欢迎查看源代码来检验下面的js代码</p>
        <div class="content">

            <script>
                var str = "Hello, World!";
                    document.write("这是我的字符串<br>");
                    document.write(str + "<br>");
                    document.write("<br>");

                    document.write("这是charAt(1)<br>");
                    document.write(str.charAt(1) + "<br>");

                    document.write("<br>");
                    document.write(".length来获取长度<br>");
                    document.write(str.length + "<br>");

                    document.write("<br>");
                    document.write("substr和cpp的substr一样的<br>");

                    document.write("document.write(str.substr(0,5))的输出是<br>");

                    document.write(str.substr(0,5));

                    document.write("<br>");
                    document.write("<br>");
                    document.write("inedxOf和cpp的find一样的<br>");

                    document.write("document.write(str.indexOf('World'))的输出是W的位置<br>");

                    document.write(str.indexOf('World'));

                    document.write("<br>");

                    document.write("<br>");
                    document.write(".split(' ')可以按照你想要的字符来分割文字<br>");

                    var strr = 'avc cc mygo!';
                    document.write("var strr = 'avc cc mygo!'<br>");

                    document.write(strr.split(' ') + "<br>");

                    document.write("<br>");
            </script>
        </div>
    </div>

    <div class="container">
        <h1>数组的一些操作</h1>
        <div class="content">
            <script>
                document.write("使用同样的 i in iterater 来遍历<br>");
                arr = [1,2,3,4,5]
                for (i in arr){
                    document.write(arr[i] + "<br>");
                }

                document.write(" isArray 检测是否是数组 返回一个布尔值<br>");

                document.write("document.write(Array.isArray(arr))<br>");

                document.write(Array.isArray(arr) + "<br>");
                document.write("<br>");

                document.write("push 可以在数组的末尾添加一个元素<br>");
                arr.push(6)
                document.write("arr.push(6)之后的arr<br>");
                document.write(arr + "<br>");
                document.write("<br>");

                document.write("pop 可以删除数组的末尾元素<br>");
                arr.pop()
                document.write("arr.pop()之后的arr<br>");
                document.write(arr + "<br>");
                document.write("<br>");

                document.write("unshift 可以在数组的开头添加一个元素<br>");
                arr.unshift(0)
                document.write("arr.unshift(0)之后的arr<br>");
                document.write(arr + "<br>");
                document.write("<br>");

                document.write("shift 可以删除数组的开头元素<br>");
                arr.shift()
                document.write("arr.shift()之后的arr<br>");
                document.write(arr + "<br>");


                document.write("<br>");
                document.write("<br>");
                document.write("join可以把数组中的元素变成字符串<br>");
                document.write("document.write(arr.join(' '))<br>");
                document.write(arr.join(' ') + "<br>");
                document.write("<br>");

                document.write("<br>");
                
            </script>
        </div>
    </div>
   
</body>
</html>